﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PayBlance.aspx.cs" Inherits="PayBlance" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>资金日核对表</title>
    <script src="../js/extTools.js" type="text/javascript"></script>
    <style>
        .x-grid-row-over .x-grid-cell-inner
        {
            font-weight: bold;
        }
        .child-row .x-grid-cell
        {
            color: red;
        }
        .adult-row .x-grid-cell
        {
            background-color: #ffffff;
            color: green;
        }
        .cw-row .x-grid-cell
        {
            background-color: #ffffff;
            color: Blue;
        }
        .x-grid-row-summary .x-grid-cell-Cost .x-grid-cell-inner
        {
            background-color: #e1e2e4;
        }
        .x-grid-row-summary .x-grid-cell-inner
        {
            font-weight: bold;
            font-size: 14px;
            background-color: #f1f2f4;
        }
        .x-column-header-inner
        {
            background-color: #157fcc;
            color: White;
            font-weight: bold;
        }
    </style>
    <script>
        var areachange = function (obj) {
            //alert(obj.value);
            CompanyX.binStock(obj.value);
        }
        var saveData = function () {
            App.Hidden1.setValue(Ext.encode(App.GridPanel1.getRowsValues({ selectedOnly: false, currentPageOnly: true })));
        };
        var getRowClass = function (record, rowIndex, rowParams, store) {
            var css = "cw-row"
            if (record.data.财务确认 == '已确认') {
                css = 'adult-row'
            }
            if (record.data.加盟商确认 == '已确认') {
                css = 'child-row'
            }
            return css;
            //return record.data.财务确认 == '已确认' ? 'child-row' : 'adult-row';
        };
        var template = '<span style="color:#fff;background-color:{0};padding: 5px 10px;">{1}</span>';
        var changesate = function (value) {
            return Ext.String.format(template, (value == '未确认') ? "red" : "green", value);
        };
        var changesate2 = function (value) {
            return Ext.String.format(template, (value == '已打款') ? "green" : "red", value);
        };
        var prepare = function (grid, toolbar, rowIndex, record) {
            var firstButton = toolbar.items.get(0);

            if (record.data.财务确认 == '已确认') {
                firstButton.setDisabled(true);
                //firstButton.setTooltip("Disabled");
            }

            //you can return false to cancel toolbar for this record
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Neptune" />
        <ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
            <Items>
                <ext:Hidden ID="FormatType" runat="server" />
                <ext:Hidden ID="Hidden1" runat="server" />
                <ext:Hidden ID="Hf_PayDate" runat="server" />
                <ext:Hidden ID="Hf_ShopCode" runat="server" />
                <ext:GridPanel ID="GridPanel1" runat="server" TitleAlign="Center">
                    <TopBar>
                        <ext:Toolbar ID="Toolbar1" runat="server" Layout="Container">
                            <Items>
                                <ext:Toolbar ID="Toolbar3" runat="server" Layout="ColumnLayout">
                                    <Items>
                                        <ext:DateField runat="server" ID="txtbdate" FieldLabel="日期" />
                                        <ext:Label ID="Label1" runat="server" Text="-">
                                        </ext:Label>
                                        <ext:DateField runat="server" ID="txtedate" />
                                        <ext:Button ID="Button1" runat="server" Text="查询" OnDirectClick="BtnQureyUser" UI="Info"
                                            Icon="Find">
                                            <DirectEvents>
                                                <Click Timeout="90000">
                                                    <EventMask ShowMask="true" Msg="加载中...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Component ID="Component2" runat="server" Width="1500" Padding="5">
                                        </ext:Component>
                                        <ext:MultiCombo runat="server" ID="txtshop" FieldLabel="店铺" DisplayField="shopname"
                                            ValueField="shopid">
                                            <Store>
                                                <ext:Store runat="server" ID="st_stock">
                                                    <Model>
                                                        <ext:Model ID="Model6" runat="server">
                                                            <Fields>
                                                                <ext:ModelField Name="shopid" />
                                                                <ext:ModelField Name="shopname" />
                                                            </Fields>
                                                        </ext:Model>
                                                    </Model>
                                                </ext:Store>
                                            </Store>
                                            <Items>
                                                <ext:ListItem>
                                                </ext:ListItem>
                                            </Items>
                                        </ext:MultiCombo>
                                        <ext:TextField runat="server" ID="txtqshop" EmptyText="输入店铺编号/名称" LabelWidth="60"
                                            FieldLabel="店铺" />
                                        <ext:ComboBox runat="server" ID="txtstates" FieldLabel="状态" Width="180" LabelWidth="60">
                                            <Items>
                                                <ext:ListItem Text="全部" Value="0" />
                                                <ext:ListItem Text="财务确认" Value="1" />
                                                <ext:ListItem Text="已打款" Value="2" />
                                                <ext:ListItem Text="加盟商确认" Value="3" />
                                            </Items>
                                            <SelectedItems>
                                                <ext:ListItem Text="全部" Value="0" />
                                            </SelectedItems>
                                        </ext:ComboBox>
                                        <ext:Component ID="Component1" runat="server" Width="1500" Padding="5" />
                                        <ext:Button ID="Button8" runat="server" Text="生成对账单" OnDirectClick="BtnCreateAcc" UI="Info">
                                            <DirectEvents>
                                                <Click Timeout="90000">
                                                    <EventMask ShowMask="true" Msg="正在生成对账单...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Button ID="Button5" runat="server" Text="消息测试" OnDirectClick="Btntest" UI="Info">
                                            <DirectEvents>
                                                <Click Timeout="90000">
                                                    <EventMask ShowMask="true" Msg="发送中...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Button ID="Button4" runat="server" Text="删除对账单" OnDirectClick="BtnDeleteAcc"
                                            UI="Danger" />
                                        <ext:Label runat="server" Margin="5" StyleSpec="color:red;" Text="溫馨提示：1.請先生成对账单进行对账。2.如果对账单有问题可以删除，重新生成对账。" />
                                        <ext:Button ID="Button6" runat="server" Text="财务打款" UI="Primary" OnClientClick="
                                        if(#{GridPanel1}.getSelectionModel().getCount()==0)
                                            Ext.Msg.alert('提示信息','请您至少选择一个店铺!');
                                        else
                                            #{Window1}.show();" />
                                        <ext:Button ID="Button7" runat="server" Text="查看小票" UI="Danger">
                                            <DirectEvents>
                                                <Click Before=" if(#{GridPanel1}.getSelectionModel().getCount()==0){
                                            Ext.Msg.alert('提示信息','请您至少选择一个店铺!')
                                            return false;
                                            }else return true;" OnEvent="BtnShowImg" />
                                            </DirectEvents>
                                        </ext:Button>
                                        <ext:Button ID="Button9" runat="server" Text="全部确认对账单" OnDirectClick="BtnCheckList" UI="Info">
                                            <DirectEvents>
                                                <Click Timeout="90000">
                                                    <EventMask ShowMask="true" Msg="全部确认中...">
                                                    </EventMask>
                                                </Click>
                                            </DirectEvents>
                                        </ext:Button>
                                    </Items>
                                </ext:Toolbar>
                            </Items>
                        </ext:Toolbar>
                    </TopBar>
                    <Store>
                        <ext:Store ID="Store1" runat="server" PageSize="3000" OnReadData="RefreshDataSet"
                            OnSubmitData="Store1_Submit">
                            <Model>
                                <ext:Model ID="Model2" runat="server">
                                    <Fields>
                                        <ext:ModelField Name="店铺代码" ServerMapping="ShopCode" Type="String" />
                                        <ext:ModelField Name="店铺简称" ServerMapping="ShopName" Type="String" />
                                        <ext:ModelField Name="销售日期" ServerMapping="saledate" Type="Date" />
                                        <ext:ModelField Name="刷卡金额" ServerMapping="BankAmount" Type="Float" />
                                        <ext:ModelField Name="现金" ServerMapping="CashAmount" Type="Float" />
                                        <ext:ModelField Name="其它收款金额" ServerMapping="OtherAmount" Type="Float" />
                                        <ext:ModelField Name="实际结算金额" ServerMapping="RealPayAmount" Type="Float" />
                                        <ext:ModelField Name="服装销售金额" ServerMapping="relfzamt" Type="Float" />
                                        <ext:ModelField Name="鞋销售金额" ServerMapping="relxamt" Type="Float" />
                                        <ext:ModelField Name="配件销售金额" ServerMapping="relpjamt" Type="Float" />
                                        <ext:ModelField Name="礼品销售金额" ServerMapping="rellpamt" Type="Float" />
                                        <ext:ModelField Name="服装分成金额" ServerMapping="fcfzamt" Type="Float" />
                                        <ext:ModelField Name="鞋分成金额" ServerMapping="fcxamt" Type="Float" />
                                        <ext:ModelField Name="配件分成金额" ServerMapping="fcpjamt" Type="Float" />
                                        <ext:ModelField Name="礼品分成金额" ServerMapping="fclpamt" Type="Float" />
                                        <ext:ModelField Name="分成合计" ServerMapping="fctot" Type="Float" />
                                        <ext:ModelField Name="预扣费用" ServerMapping="fyamt" Type="Float" />
                                        <ext:ModelField Name="本期应回款" ServerMapping="payclamt" Type="Float" />
                                        <ext:ModelField Name="工资扣款" ServerMapping="pay1" Type="Float" />
                                        <ext:ModelField Name="垫支费" ServerMapping="pay2" Type="Float" />
                                        <ext:ModelField Name="上期欠款" ServerMapping="PeriAmount" Type="Float" />
                                        <ext:ModelField Name="期初欠款" ServerMapping="BgAmount" Type="Float" />
                                        <ext:ModelField Name="本期应返还货款" ServerMapping="sjpayclamt" Type="Float" />
                                        <ext:ModelField Name="门店打款金额" ServerMapping="sjpayclamt2" Type="Float" />
                                        <ext:ModelField Name="期末余额" ServerMapping="endAmount" Type="Float" />
                                        <ext:ModelField Name="财务付款金额" ServerMapping="payamount" Type="Float" />
                                        <ext:ModelField Name="存入公司账户" ServerMapping="paycompamt" Type="Float" />
                                        <ext:ModelField Name="财务确认" ServerMapping="cwstate" Type="String" />
                                        <ext:ModelField Name="门店状态" ServerMapping="dzstate" Type="String" />
                                        <ext:ModelField Name="小票确认" ServerMapping="redsate" Type="String" />
                                        <ext:ModelField Name="加盟商确认" ServerMapping="clstate" Type="String" />
                                        <ext:ModelField Name="加盟商备注" ServerMapping="remark" Type="String" />
                                    </Fields>
                                </ext:Model>
                            </Model>
                        </ext:Store>
                    </Store>
                    <ColumnModel>
                        <Columns>
                            <ext:RowNumbererColumn runat="server" Width="50" Header="序号" Text="序号" />
                            <ext:Column ID="Column1" runat="server" Text="店铺代码" DataIndex="店铺代码" Width="80" Locked="True">
                                <Editor>
                                    <ext:TextField runat="server" />
                                </Editor>
                            </ext:Column>
                            <ext:Column ID="Column2" runat="server" Text="店铺简称" DataIndex="店铺简称" Width="150"
                                Locked="True" SummaryType="Count">
                                <SummaryRenderer Handler="return ((value === 0 || value > 1) ? '合计：(' + value +' 记录)' : '合计：(1 记录)');" />
                            </ext:Column>
                            <ext:Column ID="Column3" runat="server" Text="销售日期" DataIndex="销售日期" Width="100"
                                Locked="True">
                                <Renderer Fn="date2" />
                            </ext:Column>
                            <ext:Column ID="Column4" runat="server" Text="刷卡金额" DataIndex="刷卡金额" Width="80" SummaryType="Sum" />
                            <ext:Column ID="Column5" runat="server" Text="现金" DataIndex="现金" Width="80" SummaryType="Sum" />
                            <ext:Column ID="Column6" runat="server" Text="其它收款金额" DataIndex="其它收款金额" Width="120"
                                SummaryType="Sum" />
                            <ext:Column ID="Column7" runat="server" Text="营业额合计" DataIndex="实际结算金额" Width="120"
                                SummaryType="Sum" />
                            <ext:Column ID="Column24" runat="server" Header="销售货品类型">
                                <Columns>
                                    <ext:Column ID="Column8" runat="server" Text="服装类" DataIndex="服装销售金额" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column20" runat="server" Text="鞋类" DataIndex="鞋销售金额" Width="80" SummaryType="Sum" />
                                    <ext:Column ID="Column21" runat="server" Text="配件类" DataIndex="配件销售金额" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column22" runat="server" Text="礼品类" DataIndex="礼品销售金额" Width="80"
                                        SummaryType="Sum" />
                                </Columns>
                            </ext:Column>
                            <ext:Column runat="server" Header="应得分成">
                                <Columns>
                                    <ext:Column ID="Column23" runat="server" Text="服装类" DataIndex="服装分成金额" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column9" runat="server" Text="鞋类" DataIndex="鞋分成金额" Width="80" SummaryType="Sum" />
                                    <ext:Column ID="Column10" runat="server" Text="配件类" DataIndex="配件分成金额" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column11" runat="server" Text="礼品类" DataIndex="礼品分成金额" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column12" runat="server" Text="分成合计" DataIndex="分成合计" Width="80"
                                        SummaryType="Sum" />
                                </Columns>
                            </ext:Column>
                            <ext:Column ID="Column25" runat="server" Header="加盟商货款">
                                <Columns>
                                    <ext:Column ID="Column13" runat="server" Text="减：预扣费用" DataIndex="预扣费用" Width="120"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column14" runat="server" Text="本期应回款" DataIndex="本期应回款" Width="120"
                                        SummaryType="Sum" />
                                        <ext:Column ID="Column33" runat="server" Text="工资扣款" DataIndex="工资扣款" Width="80"
                                        SummaryType="Sum" />
                                        <ext:Column ID="Column34" runat="server" Text="垫支费" DataIndex="垫支费" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column16" runat="server" Text="上期欠款" DataIndex="上期欠款" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column27" runat="server" Text="期初欠款" DataIndex="期初欠款" Width="80"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column15" runat="server" Text="本期应返还货款" DataIndex="本期应返还货款" Width="120"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column28" runat="server" Text="存至客户卡现金" DataIndex="门店打款金额" Width="120"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column29" runat="server" Text="期末余额" DataIndex="期末余额" Width="100"
                                        SummaryType="Sum" />
                                    <ext:Column ID="Column31" runat="server" Text="财务付款金额" DataIndex="财务付款金额" Width="120"
                                        SummaryType="Sum" />
                                </Columns>
                            </ext:Column>
                            <ext:Column ID="Column17" runat="server" Text="存至归集卡现金" DataIndex="存入公司账户" Width="120"
                                SummaryType="Sum" />
                            <ext:Column ID="Column26" runat="server" Header="确认状态">
                                <Columns>
                                    <ext:Column ID="Column18" runat="server" Text="财务" DataIndex="财务确认" Width="80">
                                        <Renderer Fn="changesate" />
                                    </ext:Column>
                                    <ext:Column ID="Column32" runat="server" Text="门店状态" DataIndex="门店状态" Width="80">
                                        <Renderer Fn="changesate2" />
                                    </ext:Column>
                                    <ext:Column ID="Column35" runat="server" Text="小票确认" DataIndex="小票确认" Width="80">
                                        <Renderer Fn="changesate" />
                                    </ext:Column>
                                    <ext:Column ID="Column19" runat="server" Text="加盟商" DataIndex="加盟商确认" Width="80">
                                        <Renderer Fn="changesate" />
                                    </ext:Column>
                                </Columns>
                            </ext:Column>
                           <%-- <ext:CommandColumn ID="CommandColumn1" runat="server" Header="财务操作" Width="100">
                                <Commands>
                                    <ext:GridCommand Icon="Accept" CommandName="CwCheck" Text="财务确认">
                                    </ext:GridCommand>
                                </Commands>
                                <PrepareToolbar Fn="prepare" />
                                <Listeners>
                                    <Command Handler="CompanyX.CwCheck(record.data.店铺代码,
                                                                       record.data.销售日期,
                                                                       record.data.本期应回款,
                                                                       record.data.期初欠款,
                                                                       record.data.本期应返还货款,
                                                                       record.data.门店打款金额,
                                                                       record.data.期末余额
                                                                       );" />
                                </Listeners>
                                <%-- <DirectEvents>
                                    <Command OnEvent="BtnCwCheck">
                                        <ExtraParams>
                                            <ext:Parameter Name="shopcode" Value="店铺代码" Mode="Raw" />
                                            <ext:Parameter Name="payclamt" Value="本期应回款" Mode="Raw" />
                                            <ext:Parameter Name="PeriAmount" Value="上期欠款" Mode="Raw" />
                                            <ext:Parameter Name="sjpayclamt" Value="本期应返还货款" Mode="Raw" />
                                        </ExtraParams>
                                    </Command>
                                </DirectEvents>
                            </ext:CommandColumn>--%>
                            <ext:ImageCommandColumn runat="server" Header="财务操作" Width="100">
                                <Commands>
                                    <ext:ImageCommand Icon="Accept" CommandName="CwCheck" Text="小票确认" />
                                </Commands>
                                <Listeners>
                                    <Command Handler="CompanyX.CwCheck(record.data.店铺代码,
                                                                       record.data.销售日期,
                                                                       record.data.本期应回款,
                                                                       record.data.期初欠款,
                                                                       record.data.本期应返还货款,
                                                                       record.data.门店打款金额,
                                                                       record.data.期末余额
                                                                       );" />
                                </Listeners>
                            </ext:ImageCommandColumn>
                            <ext:Column ID="Column30" runat="server" Text="加盟商备注" DataIndex="加盟商备注" Width="120" />
                            <ext:CommandColumn ID="CommandColumn2" runat="server" Header="加盟商操作" Width="100"
                                Visible="false">
                                <Commands>
                                    <ext:GridCommand Icon="Tick" CommandName="CwCheck" Text="加盟商确认">
                                    </ext:GridCommand>
                                </Commands>
                            </ext:CommandColumn>
                        </Columns>
                    </ColumnModel>
                    <View>
                        <ext:GridView>
                            <GetRowClass Fn="getRowClass">
                            </GetRowClass>
                        </ext:GridView>
                    </View>
                    <Plugins>
                        <ext:CellEditing ID="CellEditing1" runat="server" />
                    </Plugins>
                    <Features>
                        <ext:Summary ID="Summary1" runat="server">
                        </ext:Summary>
                    </Features>
                    <SelectionModel>
                        <ext:CheckboxSelectionModel ID="RowSelectionModel3" runat="server">
                            <Listeners>
                                <Select Handler="App.Hf_PayDate.setValue(Ext.util.Format.date(record.data.销售日期, 'Y-m-d'));
                                App.Hf_ShopCode.setValue(record.data.店铺代码);">
                                </Select>
                            </Listeners>
                        </ext:CheckboxSelectionModel>
                    </SelectionModel>
                    <BottomBar>
                        <ext:PagingToolbar ID="PagingToolbar1" runat="server">
                            <Items>
                                <ext:Label ID="Label2" runat="server" Text="每页显示:" />
                                <ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
                                <ext:ComboBox ID="ComboBox1" runat="server" Width="80">
                                    <Items>
                                        <ext:ListItem Text="1000" />
                                        <ext:ListItem Text="2500" />
                                        <ext:ListItem Text="3000" />
                                        <ext:ListItem Text="3500" />
                                    </Items>
                                    <SelectedItems>
                                        <ext:ListItem Value="3000" />
                                    </SelectedItems>
                                    <Listeners>
                                        <Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
                                    </Listeners>
                                </ext:ComboBox>
                                <ext:Button ID="Button2" runat="server" Text="导出Excel" Icon="PageExcel" Visible="false">
                                    <Listeners>
                                        <Click Handler="exportData('xls');" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Button ID="Button3" runat="server" Text="导出(当前页)" AutoPostBack="true" OnClick="ToExcel"
                                    Icon="PageExcel">
                                    <Listeners>
                                        <Click Fn="saveData" />
                                    </Listeners>
                                </ext:Button>
                                <ext:Label ID="Label3" runat="server" StyleSpec="color:red;" Text="提示：请使用分批导出功能！">
                                </ext:Label>
                            </Items>
                            <Plugins>
                                <ext:ProgressBarPager ID="ProgressBarPager1" runat="server" />
                            </Plugins>
                        </ext:PagingToolbar>
                    </BottomBar>
                    <Listeners>
                        <AfterLayout Handler="#{ToolbarDroppable1}.addDDGroup(this.child('headercontainer').reorderer.dragZone.ddGroup); doSort();"
                            Single="true" />
                    </Listeners>
                </ext:GridPanel>
                <ext:Window ID="Window1" runat="server" Title="财务打款" Icon="Accept" Height="120" Width="300"
                    BodyStyle="background-color: #fff;" BodyPadding="5" Hidden="true" Modal="true">
                    <Items>
                        <ext:TextField ID="txtpaymoney" FieldLabel="打款金额" runat="server" EmptyText="输入打款金额" />
                    </Items>
                    <Buttons>
                        <ext:Button runat="server" Text="确定" OnDirectClick="BtnCwpay">
                        </ext:Button>
                        <ext:Button runat="server" Text="取消" OnClientClick="#{Window1}.hide();">
                        </ext:Button>
                    </Buttons>
                </ext:Window>
                <ext:Window ID="Window2" runat="server" Title="显示小票" Icon="Accept" Height="300" Width="500"
                    BodyStyle="background-color: #fff;" BodyPadding="5" Hidden="true" Modal="true">
                    <Items>
                        <ext:GridPanel ID="GridPanel2" runat="server">
                            <Store>
                                <ext:Store ID="Store2" runat="server">
                                    <Model>
                                        <ext:Model ID="Model1" runat="server" IDProperty="name">
                                            <Fields>
                                                <ext:ModelField Name="imgulr" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <ColumnModel>
                                <Columns>
                                    <ext:TemplateColumn ID="TemplateColumn1" runat="server" Text="店铺上传的小票" Flex="1" DataIndex="url"
                                        TemplateString='{imgulr}' />
                                </Columns>
                            </ColumnModel>
                            <View>
                                <ext:GridView ID="GridView1" runat="server" EmptyText="没有图片显示" />
                            </View>
                        </ext:GridPanel>
                    </Items>
                </ext:Window>
            </Items>
        </ext:Viewport>
    </div>
    </form>
</body>
</html>
